<template>

  <div>
    <div>
      <el-breadcrumb separator="/">
        <el-breadcrumb-item :to="{ path: '/welcome3' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item :to="{ path: $route.path }">{{ $route.meta.title }}</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <!--    <div>-->
    <el-select v-model="value" placeholder="请选择任务名称" size="mini">
      <el-option
          v-for="item in options"
          :key="item.value"
          :label="item.label"
          :value="item.value">
      </el-option>
    </el-select>
    <el-input v-model="search2" placeholder="请输入学校名称" style="width: 12%;margin-left: 10px" size="mini"></el-input>
    <span style="margin-left: 10px;margin-right: 10px">完成状态</span>
    <el-radio v-model="radio1" label="1">已完成</el-radio>
    <el-radio v-model="radio1" label="2">未完成</el-radio>
    <span style="margin-left: 10px;margin-right: 10px">评审状态</span>
    <el-radio v-model="radio2" label="1">是</el-radio>
    <el-radio v-model="radio2" label="2">否</el-radio>
    <span style="margin-left: 10px;margin-right: 10px">任务状态</span>
    <el-radio v-model="radio3" label="1">未开始</el-radio>
    <el-radio v-model="radio3" label="2">进行中</el-radio>
    <el-radio v-model="radio3" label="3">已过期</el-radio>
<!--    <el-input v-model="search" placeholder="请输入要查询的字段的值" style="width: 20%;margin-left: 10px" size="mini"></el-input>-->
    <el-button type="primary" style="margin-top: 10px;margin-left: 10px" @click="ShowSearch()" icon="el-icon-search" size="mini">查询</el-button>
    <!--    </div>-->
    <div style="margin-top: 10px;margin-bottom: 10px">
      <el-button
          size="mini"
          type="primary"
          style="width: 160px"
          class="handle-del mr10"
          @click="ShowAllTA"
      >展示所有数据</el-button>
      <el-button
          size="mini"
          style="width: 160px"
          type="primary"
          class="handle-del mr10"
          @click="Export()"
          icon="el-icon-download"
      >导出</el-button>
    </div>
    <el-table
        size="mini"
        :data=this.tableData
        :row-style="{height:'10px'}"
        :cell-style="{padding:'0px'}"
        border
        :header-cell-style="{background:'lightblue',color:'#262626'}"
        style="width: 911px">
<!--      <el-table-column-->
<!--          prop="evaluatetaskid"-->
<!--          label="任务号"-->
<!--          align="center"-->
<!--          width="80">-->
<!--      </el-table-column>-->
      <el-table-column
          prop="evaluatetaskname"
          label="任务名称"
          align="center"
          width="180">
      </el-table-column>
      <el-table-column
          prop="schoolname"
          label="学校名称"
          align="center"
          width="280">
      </el-table-column>
      <el-table-column
          prop="isfinished"
          label="是否完成"
          align="center"
          width="80">
      </el-table-column>
      <el-table-column
          prop="isfinished"
          label="是否评审"
          align="center"
          width="80">
      </el-table-column>
      <el-table-column
          prop="evaluateattitude"
          label="任务状态"
          align="center"
          width="80">
      </el-table-column>
      <el-table-column
          label="操作"
          align="center"
          width="210">
        <template slot-scope="scope">
          <el-button @click="detail(scope.row),dialogFormVisible2 = true" type="text" size="small">查看详情</el-button>
          <el-button @click="Evaluate(scope.row)" type="text" size="small">查看评估</el-button>
          <el-button @click="edit(scope.row),dialogFormVisible = true" type="text" size="small">修改</el-button>
          <el-button @click="del(scope.row)" type="text" size="small">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-table
        :data=this.tableData1
        border
        hidden
        id="out-table1"
        :header-cell-style="{background:'lightblue',color:'#262626'}"
        style="width: 461px">
      <el-table-column
          prop="evaluatetaskid"
          label="任务号"
          width="80">
      </el-table-column>
      <el-table-column
          prop="schoolname"
          label="学校名称"
          width="280">
      </el-table-column>
    </el-table>
    <el-pagination
        background
        style="margin-top: 10px"
        layout="prev, pager, next"
        page-size="15"
        v-show="isShow"
        :total="total"
        @current-change="page">
    </el-pagination>
    <!--    修改/删除的弹框-->
    <el-dialog :title=this.modeName :visible.sync="dialogFormVisible" :show-close=false width="950px">
      <hr style="margin-top: -30px;margin-bottom: 10px">
      <el-form :model="ruleForm" :rules="rules" :inline="true" ref="ruleForm" label-width="180px" class="demo-ruleForm">
        <el-form-item label="评估任务号" prop="evaluatetaskid">
          <el-input v-model="ruleForm.evaluatetaskid"></el-input>
        </el-form-item>
        <el-form-item label="学校名称" prop="schoolname">
          <el-input v-model="ruleForm.schoolname"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm('ruleForm'),allid=''">确定</el-button>
<!--        <el-button @click="resetForm('ruleForm')">重置</el-button>-->
        <el-button @click="dialogFormVisible = false,allid=''">取 消</el-button>
        <!--        <el-button type="primary" @click="dialogFormVisible = false">确 定</el-button>-->
      </div>
    </el-dialog>
    <!--    查看详情的弹框-->
    <el-dialog title="评估任务信息" :visible.sync="dialogFormVisible2" :show-close=false width="1366px">
      <hr style="margin-top: -30px;margin-bottom: 10px">
      <el-table
          size="mini"
          :row-style="{height:'10px'}"
          :cell-style="{padding:'0px'}"
          :data=tableData2
          border
          :header-cell-style="{background:'lightblue',color:'#262626'}"
          style="width: 1366px">
        <el-table-column
            prop="evaluatetaskid"
            label="评估任务号"
            align="center"
            width="95">
        </el-table-column>
        <el-table-column
            prop="evaluatetaskname"
            label="评估任务名称"
            align="center"
            width="150">
        </el-table-column>
        <el-table-column
            prop="evaluateid"
            label="评估号"
            align="center"
            width="80">
        </el-table-column>
        <el-table-column
            prop="evaluatetaskopentime"
            label="评估任务开始时间"
            align="center"
            width="180">
        </el-table-column>
        <el-table-column
            prop="evaluatetaskendtime"
            label="评估任务结束时间"
            align="center"
            width="180">
        </el-table-column>
        <el-table-column
            prop="evaluatetaskcontent"
            label="评估任务内容"
            align="center"
            width="300">
        </el-table-column>
        <el-table-column
            prop="selectedschoolnumber"
            label="已选学校数"
            align="center"
            width="80">
        </el-table-column>
      </el-table>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible2 = false">取 消</el-button>
      </div>
    </el-dialog>
    <!--    查看学校填写的信息(树形结构)-->
    <el-dialog title="已提交的评估任务信息" :visible.sync="dialogFormVisible3" :show-close=false width="1366px">
      <hr style="margin-top: -30px;margin-bottom: 10px">
      <!--      学校提交的信息(包括专家评审信息)-->
<!--      <div v-if="successTotal().total===successTotal().finished">全部完成</div>-->
<!--      <span>完成统计:{{successTotal().finished}}/{{successTotal().total}}</span>-->
      <el-tree
          :data="tableDataTree"
          :props="defaultProps"
          ref="menuTree"
          node-key="label"
          active-class="active"
          accordion
          @node-click="handleNodeClick">
        <template class="custom-tree-node" v-slot="{ node, data }">
            <span>
              <span v-if="node.data.evaluateid">({{index1SuccessNum(node)}}/{{node.data.children.length}}) </span>
              <span v-if="node.data.evaluateindex1id&&node.data.evaluateindex2id">({{index2SuccessNum(node)}}/{{node.data.children.length}}) </span>
              <!--              <i class="el-icon-success"></i>-->

              <!--              <i class="el-icon-star-on" v-show="node.data.evaluateindex3id&&node.data.success"></i>-->
              <!--              <i class="el-icon-star-off" v-show="node.data.evaluateindex3id&&!node.data.success"></i>-->
              <i class="el-icon-star-on" v-show="node.data.evaluateindex3id&&node.data.expertsuccess"></i>
              <i class="el-icon-star-off" v-show="node.data.evaluateindex3id&&!node.data.expertsuccess"></i>
              {{ node.label}}
            </span>
        </template>
      </el-tree>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="dialogFormVisible3 = false">确定</el-button>
        <el-button @click="dialogFormVisible3 = false">取 消</el-button>
      </div>
    </el-dialog>
    <!--    填写/查看评价意见的弹窗-->
<!--    <el-dialog :visible.sync="dialogFormVisible4" :show-close=false width="906px">-->
<!--      &lt;!&ndash;      <hr style="margin-top: -30px;margin-bottom: 10px">&ndash;&gt;-->
<!--      &lt;!&ndash;      学校提交的信息(包括专家评审信息)&ndash;&gt;-->
<!--      <el-card style="width:90%; margin-left: 20px;margin-right: 80px; padding-top: 0px; margin-bottom: 0px ">-->
<!--        <el-form ref="form" :model="form" :rules="rules" label-width="120px" >-->
<!--          <el-form-item class="title" label="指标内容：">-->
<!--            <div style="font-size: 18px">{{index3Label}}</div>-->
<!--          </el-form-item>-->
<!--          <el-divider></el-divider>-->
<!--          <el-form-item label="符合要求" prop="submitcontent.complete">-->
<!--            <el-radio-group v-model="form.submitcontent.complete" disabled>-->
<!--              <el-radio label="是" ></el-radio>-->
<!--              <el-radio label="否" ></el-radio>-->
<!--            </el-radio-group>-->
<!--          </el-form-item>-->
<!--          <el-form-item label="补充描述" style="width: 500px; " prop="submitcontent.desc">-->
<!--            <el-input type="textarea"-->
<!--                      disabled-->
<!--                      v-model="form.submitcontent.desc"-->
<!--                      placeholder="请输入描述内容"-->
<!--                      :rows='8'-->
<!--                      maxlength="800"-->
<!--                      show-word-limit-->
<!--                      style="width: 600px"-->
<!--            ></el-input>-->
<!--          </el-form-item>-->
<!--          <el-form-item label="已上传文件" >-->
<!--            <div v-for="file in this.uploadedfiles" :key="file.submitfilepath" class="text item" style="margin-bottom: 10px">-->
<!--              <el-link type="primary" :href="file.submitfilememo">{{'●' + file.submitfilename }}</el-link>-->
<!--            </div>-->
<!--          </el-form-item>-->
<!--        </el-form>-->
<!--      </el-card>-->
<!--      <el-card style=" margin-left: 10px; margin-right: 20px; margin-top: 10px;width:90%; margin-left: 20px">-->
<!--        <span style="font-size: 20px;">专家评审</span>-->
<!--        <el-divider></el-divider>-->
<!--        <el-form ref="expertform" :model="expertform" :rules="expertrules" label-width="120px">-->
<!--          <el-form-item label="评估内容" style="width: 500px;margin-top: 20px " prop="adv">-->
<!--            <el-input type="textarea"-->
<!--                      disabled-->
<!--                      v-model="expertform.adv"-->
<!--                      placeholder="请输入评估内容"-->
<!--                      :rows='8'-->
<!--                      maxlength="800"-->
<!--                      show-word-limit-->
<!--                      style="width: 600px"-->
<!--            ></el-input>-->
<!--          </el-form-item>-->
<!--&lt;!&ndash;          <el-form-item>&ndash;&gt;-->
<!--&lt;!&ndash;            <el-button type="primary" @click="submitAdvice" icon="el-icon-upload2">提交点评</el-button>&ndash;&gt;-->
<!--&lt;!&ndash;            <el-button @click="">取消</el-button>&ndash;&gt;-->
<!--&lt;!&ndash;          </el-form-item>&ndash;&gt;-->
<!--        </el-form>-->
<!--      </el-card>-->
<!--      &lt;!&ndash;      <el-button type="primary" @click="onSubmit('form')" icon="el-icon-upload2">保存提交</el-button>&ndash;&gt;-->
<!--      <div slot="footer" class="dialog-footer">-->
<!--        <el-button type="primary" @click="sendResultToSchool">确定</el-button>-->
<!--        <el-button @click="dialogFormVisible4 = false">取 消</el-button>-->
<!--      </div>-->
<!--    </el-dialog>-->
    <el-dialog  :visible.sync="dialogFormVisible4" :show-close=false width="906px">
      <!--      <hr style="margin-top: -30px;margin-bottom: 10px">-->
      <!--      学校提交的信息(包括专家评审信息)-->
      <el-card style="width:90%; margin-left: 20px">
        <el-form ref="form" :model="form" :rules="rules" label-width="120px" >
          <el-form-item label="指标内容">
            <div style="font-size: 18px">{{index3Label}}</div>
          </el-form-item>
          <el-divider></el-divider>
          <el-form-item label="符合要求" prop="submitcontent.complete">
            <el-radio-group v-model="form.submitcontent.complete" disabled>
              <el-radio label="是" ></el-radio>
              <el-radio label="否" ></el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="补充描述" style="width: 500px; " prop="submitcontent.desc">
            <el-input type="textarea"
                      disabled
                      v-model="form.submitcontent.desc"
                      placeholder="请输入描述内容"
                      :rows='8'
                      maxlength="800"
                      show-word-limit
            ></el-input>
          </el-form-item>
          <el-form-item label="已上传文件" >
            <div v-for="file in this.uploadedfiles" :key="file.submitfilepath" class="text item" style="margin-bottom: 10px">
              <el-link type="primary" :href="file.submitfilememo">{{'●' + file.submitfilename }}</el-link>
            </div>
          </el-form-item>
        </el-form>
      </el-card>
      <el-card style=" margin-left: 10px; margin-right: 20px; margin-top: 10px;width:90%; margin-left: 20px">
        <span style="font-size: 20px;">专家评审</span>
        <el-divider></el-divider>
        <el-form ref="expertform" :model="expertform" :rules="expertrules" label-width="120px">
          <el-form-item label="评估内容" style="width: 500px; " prop="adv">
            <el-input type="textarea"
                      v-model="expertform.adv"
                      placeholder="请输入评估内容"
                      :rows='8'
                      maxlength="800"
                      show-word-limit
                      style="width: 500px"
            ></el-input>
          </el-form-item>
          <el-form-item>
            <!--                        评审完后 更新数据库-->
            <el-button type="primary" @click="submitAdvice" icon="el-icon-upload2">提交点评</el-button>
            <!--                        <el-button @click="">取消</el-button>-->
          </el-form-item>
        </el-form>
      </el-card>

      <!--      <el-button type="primary" @click="onSubmit('form')" icon="el-icon-upload2">保存提交</el-button>-->
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="sendResultToSchool">确定</el-button>
        <el-button @click="dialogFormVisible4 = false">取 消</el-button>
      </div>
    </el-dialog>

  </div>
</template>

<script>
import variables from "@/assets/variables.scss";

export default {
  methods:{
    page(currentPage){
      const _this=this
      this.returnPage=currentPage
      axios.get('http://localhost:8081/evaluatetaskarrange/page?current='+currentPage+'&size=15').then(function (res) {
        // console.log(res.data)
        _this.tableData = res.data.evaluatetaskarrangeList;
        _this.total = res.data.total;
      })
    },
    submitForm(formName) {
      const _this=this
      this.$refs[formName].validate((valid) => {
        if (valid) {
          if (this.allid){
            axios.put("http://localhost:8081/evaluatetaskarrange/update",this.ruleForm).then(function (res){
              if (res.data.msg==="更新成功"){
                _this.$message({
                  message: '更新成功！',
                  type: 'success'
                  //添加成功后页面跳转
                });
                // _this.$router.push('/EvaluateTaskArrange')
                _this.dialogFormVisible=false
                this.ShowAllTA()
              }
              else{
                _this.$message({
                  message: '评估任务号不存在或者学校不存在！请重新输入',
                  type: 'fail'
                });
              }
            })
          }
          else {
            axios.post("http://localhost:8081/evaluatetaskarrange/save/",this.ruleForm).then(function (res){
              if (res.data.msg==="发布成功"){
                _this.$message({
                  message: '发布成功！',
                  type: 'success'
                  //添加成功后页面跳转
                });
                // _this.$router.push('/EvaluateTaskArrange')
                _this.dialogFormVisible=false
                this.ShowAllTA()
              }
              else{
                _this.$message({
                  message: '该学校不存在或者评估任务号不存在！请重新输入',
                  type: 'fail'
                });
              }
            })
          }
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    },
    ShowAllTA(){
      const _this=this
      axios.get('http://localhost:8081/evaluatetaskarrange/findAll').then(function (res){
        _this.tableData=res.data
      })
    },
    ShowSearch(){
      const _this=this
      // axios.get("http://localhost:8081/evaluatetaskarrange/search/"+this.value+'/'+this.search).then(function (res){
      //   _this.tableData=res.data
      //   _this.search=''
      // })
      this.isShow=false
      let tranR1;
      let tranR2;
      let tranR3;
      if (this.value===''){
        this.value='all'
      }
      if (this.search2===''){
        this.search2='all'
      }
      if(this.radio1==='1'){
          tranR1='是'
      }
      if(this.radio1==='2'){
        tranR1='否'
      }
      if(this.radio2==='1'){
        tranR2='是'
      }
      if(this.radio2==='2'){
        tranR2='否'
      }
      if(this.radio3==='1'){
        tranR3='未开始'
      }
      if(this.radio3==='2'){
        tranR3='进行中'
      }
      if(this.radio3==='3'){
        tranR3='已过期'
      }
      let searchUrl=this.value+'/'+this.search2+'/'+tranR1+'/'+tranR2+'/'+tranR3
      axios.get("http://localhost:8081/evaluatetaskarrange/searchmorethanone/"+searchUrl).then(function (res){
        _this.tableData=res.data
      })
      this.value=''
      this.search2=''
    },
    Export(){
      let tables = document.getElementById("out-table1");
      console.log(tables)
      let table_book = this.$XLSX.utils.table_to_book(tables);
      var table_write = this.$XLSX.write(table_book, {
        bookType: "xlsx",
        bookSST: true,
        type: "array"
      });
      try {
        this.$FileSaver.saveAs(
            new Blob([table_write], { type: "application/octet-stream" }),
            "EvaluateTaskArrange.xlsx"
        );
      } catch (e) {
        if (typeof console !== "undefined") console.log(e, table_write);
      }
      return table_write;
    },
    TAAdd(){
      this.dialogFormVisible = true;
      this.modeName='添加评价安排'
      this.ruleForm={}
    },
    edit(row){
      this.dialogFormVisible = true
      this.modeName='更新评价安排'

      this.ruleForm=row
      this.allid=row.id
    },
    del(row){
      const _this=this
      const d=confirm("确定删除吗？");
      if (d){
        axios.delete('http://localhost:8081/evaluatetaskarrange/delete/'+row.id).then(()=>{
          axios.get("http://localhost:8081/evaluatetask/search/1/"+row.evaluatetaskid).then((res)=>{
            console.log(res.data[0])
            res.data[0].selectedschoolnumber=res.data[0].selectedschoolnumber-1
            axios.put("http://localhost:8081/evaluatetask/update",res.data[0]).then((res)=>{
            })
          })
          alert("删除成功")
          // location.reload();
          if((this.total-1)% 15===0){
            this.page(this.returnPage-1)
          }
          else {
            this.page(this.returnPage)
          }
        })
      }
    },
    detail(row) {
      axios.get("http://localhost:8081/evaluatetask/search/1/"+row.evaluatetaskid).then((res)=>{
        res.data.evaluatetaskopentime=this.$moment(res.data.evaluatetaskopentime).format('YYYY-MM-DD HH:mm:ss')
        res.data.evaluatetaskendtime=this.$moment(res.data.evaluatetaskendtime).format('YYYY-MM-DD HH:mm:ss')
        let time=new Date().getTime()
        let ot=new Date(res.data.evaluatetaskopentime).getTime()
        let et=new Date(res.data.evaluatetaskendtime).getTime()
        if  (time>=et){
          //已结束
          res.data.evaluateattitude='已过期'
        }
        else if (time<et && time >=ot){
          //进行中
          res.data.evaluateattitude='进行中'
        }
        else {
          //未开始
          res.data.evaluateattitude='未开始'
        }
        this.tableData2=res.data
      })
    },
    Evaluate(row){
      console.log(row)
      this.evaluateSchoolname=row.schoolname
      //根据学校名和任务号 检索出此任务评估填写信息
      if (row.evaluateattitude==='未开始'){
        alert('未开始')
      }
      else if (row.evaluateattitude==='已过期'){
        alert('已过期')
      }
      else if (row.isfinished==='否'){
        alert('学校还未完成评估')
      }
      else {
      this.dialogFormVisible3=true
      // axios.get("http://localhost:8081/evaluatetree/"+ row.schoolname).then((res)=>{
      //   console.log(res.data)
      //   this.$store.commit('setTreeTable',res.data)
      //   this.tableDataTree= this.$store.state.treeTable
      //   console.log(this.tableDataTree)
      // })
      axios.get('http://localhost:8081/schooluser/selectone/3/'+row.schoolname).then((res)=>{
        this.$store.commit('setSchoolId',res.data.id)
        this.$store.commit('setSchoolname',res.data.schoolname)
        this.schoolname=this.$store.state.schoolname
        // 判断info字段是否为空
        if(res.data.info)
        {
          this.tableDataTree = JSON.parse(res.data.info)
        }else{
          // info为空 学校没有过提交记录
          axios.get('http://localhost:8081/evaluatetree/'+this.schoolname).then( (res)=>{
            this.$store.commit('setTreeTable',res.data)
            this.tableDataTree= this.$store.state.treeTable
            // console.log(this.tableData)
          })
        }
      })
      }
    },
    sendResultToSchool(){
      //评审完成后 点击确定传回学校端/评委端 是否评审改为是
      this.dialogFormVisible4=false
    },
    // 星星
    update(label){
      const node = this.$refs.menuTree.getNode(label)
      // node.data.success = true
      node.data.expertsuccess=true
      node.data = JSON.parse(JSON.stringify(node.data))
      // console.log('父组件中的方法-----')
      // 更新学习用户完成情况（info字段）
      let data = {
        id: this.$store.state.schoolId,
        info: JSON.stringify(this.tableDataTree)
      }
      axios.post('http://localhost:8081/schooltask/respost',data).then((res)=>{
        // console.log(res)
      })
    },
    // 点击节点事件
    handleNodeClick(data, node){
      const a = this.$refs.menuTree.getNode(data.label)
      this.aa=a.data
      // 找到叶子节点
      if (a.isLeaf){
        // alert('开始评估')
        console.log('a',a.data)
        this.dialogFormVisible4=true
        this.index3Label=a.data.label
        axios.get('http://localhost:8081/getRightTaskId/'+this.evaluateSchoolname).then((res)=>{
          this.form.evaluatetaskid =res.data
          this.form.evaluateindex3id=a.data.evaluateindex3id
          this.form.schoolname=this.evaluateSchoolname
          // 查询提交内容
          // if (this.evaluate.success) {
          if  (a.data.success){
            axios.get(`http://localhost:8081/submit/search/${this.evaluateSchoolname}/${this.form.evaluatetaskid}/${a.data.evaluateindex3id}`).then(res => {
              console.log('sadasdasdas', res.data)
              let content = JSON.parse(res.data.submitcontent)
              this.form.submitcontent.complete = content.complete
              this.form.submitcontent.desc = content.desc
              this.form.submitcontent.filesnum = content.filesnum
              this.expertform.adv = content.advice
              // console.log('提交内容',res.data);
              // 拿着res.data.id 查表submitfiles
              axios.get(`http://localhost:8081/submit/searchfiles/${res.data.id}`).then(res => {
                // console.log('已上传文件',res.data);
                this.uploadedfiles = res.data
              })
            })
          }
          else{
            // 清空表单
            this.$nextTick(()=>{
              this.resetForm('form')
              this.$refs.upload.clearFiles()
              this.progressFlag=false
              this.progress=0
              this.uploadedfiles=[]
            })
          }
        })
      }
    },
    // StartEvaluate 的方法
    handleChange(file, fileList){
      this.fileList = fileList
    },
    handleExceed(files, fileList) {
      this.$message.warning(`当前限制选择 5 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList.length} 个文件`);
    },
    handleRemove(file, fileList) {
      console.log(file, fileList);
    },
    handlePreview(file) {
      console.log(file);
    },
    onSubmit(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          console.log('submit!');
          this.progressFlag=true
          // console.log(this.form);
          this.form.submitcontent.filesnum = this.fileList.length
          let formData = new FormData()
          this.fileList.forEach(item=>{
            formData.append('files', item.raw)
          });
          formData.append('form', JSON.stringify(this.form))
          const _this = this
          axios({
            url: 'http://localhost:8081/files/upload',
            method: 'POST',
            data: formData,
            // eslint-disable-next-line eqeqeq
            onUploadProgress: (progressEvent) => {
              // eslint-disable-next-line
              let complete = (progressEvent.loaded / progressEvent.total * 100 | 0)
              // 这里为上传的进度
              _this.progress = complete;
            },
          }).then((res) => {
            // console.log('post返回值' + res)
            setTimeout(res=>{
              if (res='success') {
                this.$message({
                  message:"提交上传成功",
                  type:"success"
                })
              } else {
                this.$message.error("提交失败")
              }
            },500)

          });
        } else {
          console.log('error submit!!');
          return false;
        }
      });
      // let ret = axios.post('http://localhost:8081/files/upload',formData).then(res=> {
      //   console.log('post返回值' + res)
      // 子路由调用父路由
      this.$emit('father', this.evaluate.label)
    },
    submitAdvice(){
      this.form.submitcontent.advice=this.expertform.adv
      this.form.submitcontent=JSON.stringify(this.form.submitcontent)
      // axios.put("http://localhost:8081/submit/update/"+this.form.schoolname+'/'+this.form.evaluatetaskid+'/'+this.form.evaluateindex3id+'/'+this.form.submitcontent).then((res)=>{
      //     console.log(res.data)
      // })

      axios.put("http://localhost:8081/submit/update",this.form).then((res)=>{
        if (res.data.msg==='更新成功'){
          alert('评价成功')
        }
        this.update(this.index3Label)
      })
    }
  },

  data(){
    return {
      search2:'',
      radio1:'1',
      radio2:'2',
      radio3:'2',
      aa: null,
      uploadedfiles:[],
      evaluateid:'',
      evaluateSchoolname:'',
      index3Label:'',
      tableDataTree:null,
      dialogTableVisible: false,
      dialogFormVisible: false,
      dialogFormVisible2: false,
      dialogFormVisible3: false,
      dialogFormVisible4: false,
      textarea:'',
      formLabelWidth: '120px',
      ruleForm: {
        // id:'',
        evaluatetaskid: '',
        schoolname: '',
        evaluatetaskname:'',
      },
      rules: {
        evaluatetaskid: [
          { required: true, message: '请填写评估任务号', trigger: 'blur' }
        ],
        schoolname: [
          { required: true, message: '请填写学校名称', trigger: 'blur' }
        ],
      },
      expertform:{
        adv:''
      },
      search:'',
      allid:'',
      isShow:true,
      mode:'',
      modeName:'',
      options: [],
      value: '',
      desc:'',
      total:null,
      returnPage:'',
      tableData: null,
      tableData1: null,
      tableData2: null,
      tableData3: null,
      tableData4: null,
      dataList: [],
      fileList: [],
      query: {"page":0, "size":20, count:0},
      column: [
        {label: "序号", prop: "id", type: "string"},
        {label: "任务号", prop: "evaluatetaskid", type: "string"},
        {label: "学校名称", prop: "schoolname", type: "string"},

      ],
      editForm: {},
      editVisible: false,
      currentIndex: null,
      form: {
        evaluateindex3id: null,
        schoolname: null,
        evaluatetaskid: null,
        submitcontent:{
          complete:'',
          progress:[],
          desc: '',
          advice:''
        }
      },
      progress: 0,
      progressFlag:false,
    }
  },
  created() {
    const _this=this
    const a=localStorage.getItem("access-admin")
    if(a){
      axios.get('http://localhost:8081/evaluatetaskarrange/page?current=1&size=15').then(function (res){
        // console.log(res.data.current)
        _this.returnPage=res.data.current;
        _this.tableData=res.data.evaluatetaskarrangeList;
        _this.total=res.data.total;
      })
      axios.get('http://localhost:8081/evaluatetaskarrange/findAll').then(function (res){
        // console.log(res.data)
        // _this.tableData=res.data
        _this.tableData1=res.data
      })
      axios.get('http://localhost:8081/evaluatetask/findAll').then((res)=>{
        console.log('rsaes',res.data)
        for(let i=0;i<res.data.length;i++){
          this.options.push({value:i+1,label:res.data[i].evaluatetaskname})
        }
      })
    }
    else{
      this.$alert('未登录','提示',{
        confirmButtonText:'确定'
      }).then((res)=>{
        this.$router.replace({path:'/login'})
      })
    }

  },
  computed:{
    index1SuccessNum(){
      return function (no){
        // console.log('计算属性参数',no)
        let cnt=0
        for (let i of no.data.children){
          let flag=1;
          for (let j of i.children){
            // if (!j.success){
            //   flag=0
            //   break;
            // }
            if (!j.expertsuccess){
              flag=0
              break;
            }
          }
          if(flag) {
            cnt+=1
          }
        }
        return cnt;
      }
    },
    // 统计二级指标完成数
    index2SuccessNum(){
      return function (no){
        let cnt=0;
        for (let i of no.data.children){
          // if(i.success){
          //   cnt++
          // }
          if(i.expertsuccess){
            cnt++
          }
        }
        return cnt
      }
    },
    // successTotal(){
    //   return function (){
    //     let total = 0
    //     let finished =0
    //     console.log('zz',this.tableDataTree)
    //     for (let i of this.tableDataTree)
    //     {
    //       for (let j of i.children){
    //         for (let k of j.children){
    //           total++
    //           if (k.success){
    //             finished++
    //           }
    //         }
    //       }
    //     }
    //     return {total:total, finished:finished}
    //   }
    // },
    variables() {
      return variables
    },

  },
}
</script>

<!--<style scoped>-->
<!--.title >>>label{-->
<!--  font-size: 1000px;-->
<!--  color: black;-->
<!--  margin-top: -10px;-->
<!--}-->
<!--.el-divider&#45;&#45;horizontal {-->
<!--  margin-top: -10px;-->
<!--  margin-bottom: 5px;-->
<!--}-->
<!--</style>-->
